import path from 'path'

const env = process.env.NODE_ENV || 'development';
const config = {
    env: env,
    path_project: path.resolve(__dirname, '../'),
    dir_src: 'src',
    dir_dist: 'dist',

    // 服务器配置
    api_target: "http://10.0.1.24:8080",
    server_host: '10.0.1.29',
    //server_port: envConfig.port || 4000,
    server_port: 4000
};

config.base_uri = "http://" + config.server_host + ":4000";

// ------------------------------------
// 配置相关环境变量
// ------------------------------------
config.globals = {
    'process.env': {
        'NODE_ENV': JSON.stringify(config.env)
    },
    'NODE_ENV': config.env,
    '__DEV__': config.env === 'development',
    '__PROD__': config.env === 'production',
    '__DEBUG__': true
};

// ------------------------------------
// Utilities
// ------------------------------------
config.utils_paths = (() => {
    const base = [config.path_project];
    const resolve = path.resolve;

    const project = (...args) => resolve.apply(resolve, [...base, ...args]);

    return {
        project: project,
        src: project.bind(null, config.dir_src),
        dist: project.bind(null, config.dir_dist)
    }
})();

export default config